<extend name="Public:User/base"/>
<block name="content">
    <div class="all-width my-cols-right info-back-color back-margin-padding col-sm-9 col-lg-9">
        <div class="row">
            <div class="small-search col-sm-12 col-lg-12">
                <!-- row-search start -->
                <div class="row">
                    <div class="small-search-a col-sm-2 col-lg-2 text-center">
                        <span style="font-size: 18px">编辑晒单</span>
                    </div>
                    <div class="col-sm-10 col-lg-10"></div>
                </div>
                <!--row-search end-->
            </div>
        </div>
        <div class="row">
            <div class="col-sm-2 col-lg-2">
                <img src="{$Think.const.IMG_URL}/index/手机平板/1-3.png" width="150" height="150">
            </div>
            <div class="col-sm-10 col-lg-10" style="margin-top: 50px;">
                <a href="#">{$goodsInfo.goodsname} &nbsp;第{$goodsInfo.lotteryturn}期</a><br>
                <span>幸运码:<span>{$goodsInfo.lotterynumber}</span></span>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12 col-lg-12" style="padding: 15px 50px;">
                <form name="share" action="__MODULE__/Share/saveShare" method="post" role="form" enctype="multipart/form-data">
                    <!--<div id="file">-->
                        <!--<div>-->
                            <!--<input type="file" class="prev" multiple>-->
                            <!--<img src="{$Think.const.IMG_URL}/personalcenter/add.png">-->
                            <!--<span class="imgCom" id="prev"></span>-->
                        <!--</div>-->
                        <!--<p>添加照片(最多添加5张照片)</p>-->
                    <!--</div>-->
                    <input type="hidden" value={$goodsInfo.userlotterid} name="userLotteryInfo_ID"/>
                    <input type="file" onchange='PreviewImage(this)' name="image"/>
                    <br />
                    <div id="imgPreview" style='width:120px; height:100px;'>
                        <img id="img2" src="" width="120" height="100" />
                        <!-- afssfafas -->
                    </div>
                    <!-- todo:多图片上传 -->
                    <div class="form-group">
                        <label>标题:</label>
                        <input type="text" class="form-control" placeholder="请输入标题" name="title" value="{$oldInfo.title}">
                    </div>
                    <div class="form-group">
                        <label>内容:{$oldInfo.sharetext}</label>
                        <textarea class="form-control" rows="10" placeholder="请输入您的感想..." name="shareText" >{$oldInfo.sharetext}</textarea>
                    </div>
                    <input class="btn button-set pull-right" style="font-size: 20px;" type="submit" value="保存草稿">
                    <input class="btn button-set pull-right" style="font-size: 20px;" type="submit" value="确认晒单">

                </form>
            </div>
        </div>
    </div>

<a href="javascript:scroll(0,0)">
    <div class="text-center" style="width:50px;height:50px;background-color: #ccc;font-size:40px;position: fixed;bottom: 20px;right:20px;">
        <span class="glyphicon glyphicon-chevron-up" aria-hidden="true"></span>
    </div>
</a>
<script>
    function previewB(file,$obj) {
        var reader = new FileReader();//创建FileReader对象
        reader.onload = function(e) {
            var $img = $('<img>').attr("src", e.target.result);
            $obj.empty().append($img);
        }
        reader.readAsDataURL(file);
    }

    $('[type=file]').change(function(e) {
        var $obj = $(document.getElementById(e.target.className));
        var file = e.target.files[0],//事件目标
                val  = $(this).val(),
                reg  = /\.(png|jpg|gif|bmp|jpeg)$/;
        if( reg.test(val) ){
            previewB(file,$obj);
        }else{
            alert('选择正确格式的图片');
        }
    })
    function PreviewImage(imgFile)
    {
        var filextension=imgFile.value.substring(imgFile.value.lastIndexOf("."),imgFile.value.length);
        filextension=filextension.toLowerCase();
        if ((filextension!='.jpg')&&(filextension!='.gif')&&(filextension!='.jpeg')&&(filextension!='.png')&&(filextension!='.bmp'))
        {
            alert("对不起，系统仅支持标准格式的照片，请您调整格式后重新上传，谢谢 !");
            imgFile.focus();
        }
        else
        {
            var path;
            if(document.all)//IE
            {
                imgFile.select();
                path = document.selection.createRange().text;
                document.getElementById("imgPreview").innerHTML="";
                document.getElementById("imgPreview").style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',sizingMethod='scale',src=\"" + path + "\")";//使用滤镜效果
            }
            else//FF
            {
                path=window.URL.createObjectURL(imgFile.files[0]);// FF 7.0以上
                //path = imgFile.files[0].getAsDataURL();// FF 3.0
                document.getElementById("imgPreview").innerHTML = "<img id='img1' width='120px' height='100px' src='"+path+"'/>";
                //document.getElementById("img1").src = path;
            }
        }
    }
</script>
</block>